package com.liuceng.zen.mapper;

import com.liuceng.zen.common.annotations.MyBatisRepository;
import com.liuceng.zen.pojo.domain.DictRegion;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@MyBatisRepository
public interface DictRegionMapper extends BaseMapper<DictRegion> {
  int insert(DictRegion record);

  int updateByPrimaryKey(DictRegion record);

  @Select({"select * from public.dict_regions where region_level = 1"})
  @ResultMap("BaseResultMap")
  public List<DictRegion> findProvinces();

  @Select({
      "select * from public.dict_regions where region_level = 2 and parent_id = #{provinceId}"})
  @ResultMap("BaseResultMap")
  public List<DictRegion> findCities(Integer provinceId);

  @Select({"select * from public.dict_regions where region_level = 3 and parent_id = #{cityId}"})
  @ResultMap("BaseResultMap")
  public List<DictRegion> findAreas(Integer cityId);

  List<String> findListNameByIds(Object[] ids);
}
